package com.kai.steering.data.service.entity.domainObject;

import cn.hutool.core.bean.BeanUtil;
import com.kai.steering.data.service.entity.dto.AnswerDTO;
import com.kai.steering.data.service.entity.dto.AnswerQueryDTO;
import com.kai.steering.data.service.entity.dto.UserQueryDTO;
import com.kai.steering.data.service.entity.po.Answer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.Date;

import lombok.*;

import java.io.Serializable;

/**
 * <pre>
 * 答案 Do对象
 * </pre>
 *
 * @author kai
 * @date 2022-02-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ToString
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "AnswerDO对象", description = "答案业务实体")
public class AnswerDO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "答案id")
    private String answerId;
    @ApiModelProperty(value = "题目id")
    private String questionId;
    @ApiModelProperty(value = "答案")
    private String answer;
    @ApiModelProperty(value = "内容")
    private String content;
    @ApiModelProperty(value = "创建时间")
    private Date creationDatetime;
    @ApiModelProperty(value = "创建人管理员id或者用户id")
    private String founder;
    @ApiModelProperty(value = "存在0删除1")
    private Integer usable;
    @ApiModelProperty(value = "删除日期")
    private Date deleteDatetime;

    public AnswerDO(String answer, String content) {
        this.answer = answer;
        this.content = content;
    }

    public AnswerDO(String answerId, String questionId, String answer, String content) {
        this.answerId = answerId;
        this.questionId = questionId;
        this.answer = answer;
        this.content = content;
    }

    public AnswerDO(AnswerQueryDTO answerQueryDTO) {
        this.convertAnswerDO(answerQueryDTO);
    }

    public AnswerDO(Answer answer) {
        this.convertAnswerDO(answer);
    }

    public AnswerDO(AnswerDTO answerDTO) {
        this.convertAnswerDO(answerDTO);

    }
    public AnswerDO convertAnswerDO(AnswerDTO answerDTO) {
        BeanUtil.copyProperties(answerDTO, this);
        return this;
    }

    /**
     * 转QueryDTO为do
     *
     * @param answerQueryDTO
     * @return
     */
    public AnswerDO convertAnswerDO(AnswerQueryDTO answerQueryDTO) {
        BeanUtil.copyProperties(answerQueryDTO, this);
        return this;
    }

    /**
     * 转po为do
     *
     * @param answer
     * @return
     */
    public AnswerDO convertAnswerDO(Answer answer) {
        BeanUtil.copyProperties(answer, this);
        return this;
    }
}